import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
testCase="DBshop009_后台销售管理--退货订单搜索流程"

firefox=openBrowser(url)
DBshopLogin(firefox,userName,password)

firefox.find_element_by_link_text("我的订单").click()
firefox.find_element_by_partial_link_text('交易完成').click()

ordernumber=firefox.find_elements_by_xpath('//table/thead/tr/th/div/a')[0].text
# firefox.find_element_by_link_text('退货申请').click()
# firefox.find_element_by_link_text('点此申请退货').click()
# firefox.find_element_by_id('order_sn').send_keys(ordernumber)
# firefox.find_element_by_id('search-order').click()
# firefox.find_element_by_xpath('//input[@value="1"]').click()
# firefox.find_element_by_id('refund_info').send_keys('不想要了！')
# firefox.find_element_by_xpath('//button[text()="申请退货"]').click()
# firefox.switch_to.alert.accept()

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'销售管理','退货管理')
Select(firefox.find_element_by_xpath('//select[@name="refund_type"]')).select_by_visible_text('退款到账户余额')
firefox.find_element_by_xpath('//button[@type="submit"]').click()

# try:
#     firefox.find_element_by_xpath('//table/tbody/tr[2]/td[1]"]').is_displayed(ordernumber)
#     writeLog("%s 测试通过"%testCase)
#     print("%s 测试通过"%testCase)
# except:
#     writeLog("%s 测试失败" % testCase)
#     getPhoto(firefox)
#     print("%s 测试失败" % testCase)

time.sleep(2)
firefox.quit()